package orfeu.engine;


import orfeu.engine.R;
import android.app.Activity;
import android.database.Cursor;
import android.os.Bundle;
import android.view.ViewGroup.LayoutParams;
import android.widget.TableLayout;
import android.widget.TableRow;
import android.widget.TextView;

public class Displayhighscores  extends Activity 
{
	@Override
	public void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
	     setContentView(R.layout.displayhighscores);
	     // Se face legatura cu tabelul
	     TableLayout tl = (TableLayout) findViewById(R.id.TableLayout01);
	     int i;
	     String info= new String();
	     DatabaseHelper bs = new DatabaseHelper(this);
	     try{
					bs.createDataBase();
					bs.openDataBase();
					long nr=0;
					Cursor c = bs.myDataBase.rawQuery("SELECT * FROM " + "highscores order by Highscore", null);
					c.moveToFirst();
					if (c != null) {
						do {
						nr++;
						
						String f2=c.getString(2);
						String f3=c.getString(0);
						
						 // se creaza un rand(TableRow) nou, 
				    	 TableRow tr=new TableRow(this);
				    	 
				    	 TextView a = new TextView(this);
				    	 a.setText(Long.toString(nr));
				    	 a.setTextSize(10);
				    	 // se adauga informatiile(TextView) in obiectul de tip rand
				    	 tr.addView(a);
				    	 
				    	 TextView t = new TextView(this);
				    	 t.setText(f2);
				    	 t.setTextSize(10);
				    	 tr.addView(t);
				    	 
				    	 TextView y = new TextView(this);
				    	 y.setText(f3);
				    	 y.setTextSize(10);
				    	 // se adauga informatiile(TextView) in obiectul de tip rand
				    	 tr.addView(y);
				    	 // se adauga randul in tablea
				    	 tl.addView(tr,new TableLayout.LayoutParams(LayoutParams.WRAP_CONTENT, LayoutParams.WRAP_CONTENT));
				     	} 
						while (c.moveToNext());
					}
		
					
					bs.close();
			}catch(Exception e){
				info = e.toString();
			}
			
	  	 	TextView t2 = new TextView(this); 
	 	// 	t2=(TextView)findViewById(R.id.result);
	 	 	t2.setText(info);   
	    
	     
	     // Pentru fiecare intrare in listele clasei statice 
	     
	}

}
